/******************************************************************************/
/*  POB-Technology 2005                                                       */
/*                                                                            */
/* File : PobTerm.c                                                           */
/* Author : Pierre Seguin                                                     */
/*                                                                            */
/* Example of form dictionnary and print on PobTerminal                       */
/*                                                                            */
/******************************************************************************/


#include <pob-eye.h>


#include "pattern.h"   /* dictionnary of forms */

int main (void)
{	
	UInt8 i=0,Nb_Identify=0;
	
	Form ListOfForm[MAX_OF_FORM];  /* list of forms	*/
	
	RGBFrame FrameFromCam;  /* struct of three pointers on the RGB components */
	
	/* system initialization */
	InitPOBEYE();
		
	/* get the pointer of the red,green and blue video buffer */
	GetPointerOnRGBFrame(&FrameFromCam);

	while(1)
	{		
		
		/* grab the RGB components */
		GrabRGBFrame();				
		
		/* binary the three RGB Buffer */
		BinaryRGBFrame(&FrameFromCam); 
		
		/* try to identify the forms and make a list of it */
		Nb_Identify=IdentifyForm(&FrameFromCam,ListOfForm,Pattern);	
	

		/* parse the list of the form and print result on the Pob-Terminal */
		for(i=0;i<Nb_Identify;i++)
		{
			switch (ListOfForm[i].id)
			{
			case IDP_0_CROSS:
				PrintTextOnPobTerminal("Cross %d %d",ListOfForm[i].x,ListOfForm[i].y);
			break;
				
			case IDP_1_BIGA:
				PrintTextOnPobTerminal("A Big A %d %d",ListOfForm[i].x,ListOfForm[i].y);
			break;

			case IDP_2_KING:
				PrintTextOnPobTerminal("The King %d %d",ListOfForm[i].x,ListOfForm[i].y);
				break;
			case IDP_3_TOWER:
				PrintTextOnPobTerminal("Tower %d %d",ListOfForm[i].x,ListOfForm[i].y);
			break;

			case IDP_4_TREFLE:
				PrintTextOnPobTerminal("Trefle %d %d",ListOfForm[i].x,ListOfForm[i].y);
			break;
			
			case IDP_5_TRIANGLE:
				PrintTextOnPobTerminal("Triangle %d %d",ListOfForm[i].x,ListOfForm[i].y);
			break;

			case IDP_6_CIRCLE:
				PrintTextOnPobTerminal("Circle %d %d",ListOfForm[i].x,ListOfForm[i].y);
			break;

			default:
			break;
			}
		}
		
	}
	return 0;
}

